package com.example.myzhugezhaofang.activity;

import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

import com.example.myzhugezhaofang.R;

public class WebActivity extends AppCompatActivity {

    private WebView web;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
        web = findViewById(R.id.web_view);
        initView();
    }

    private void initView() {
        WebSettings settings = web.getSettings();
        /*settings.setUseWideViewPort(true);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setLoadWithOverviewMode(true);*/
        //支持javascript
        settings.setJavaScriptEnabled(true);
        //扩大比例的缩放
        //settings.setUseWideViewPort(true);
        //自适应屏幕
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setLoadWithOverviewMode(false);
        // 设置可以支持缩放
        settings.setSupportZoom(false);
// 设置出现缩放工具
        settings.setBuiltInZoomControls(false);
//自适应屏幕
      /*  web.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        web.getSettings().setLoadWithOverviewMode(true);*/
        Intent intent = getIntent();
        String link = intent.getStringExtra("link");
        web.setWebViewClient(new WebViewClient());
        web.loadUrl(link);

    }
}